import React, { Component } from 'react';
import { Router, Route, IndexRoute } from 'react-router';
import App from 'common/containers/App.js';
import Error from 'common/containers/Error.js';
import 'common/containers/app.less';

import Main from '../main/Main.js';
import Detail from '../detail/Detail.js';

/**
 * 路由
 */
class RouteMap extends Component{

	onUpdate = () => {
		window.scrollTo(0,0);
	}

	render(){
		return(
			<Router history={this.props.history} onUpdate={this.onUpdate}>
				<Route path="/" component={App}>
					<IndexRoute component={Main}/>
					<Route path="/detail/:videoId" component={Detail}/>
					<Route path="*" component={Error}/>
				</Route>
			</Router>
		)
	}
}

export default RouteMap;